package file;import org.junit.Test;
import sun.management.snmp.jvmmib.JVM_MANAGEMENT_MIBOidTable;

import java.io.File;
import java.io.IOException;

public class newFileMethod {
    public static void main(String[] s){

    }
    //创造文件的三种方法
    //1.new File(filePath)通过路径创建File
    @Test
    public void create01O() throws IOException {
        String filePath="D:\\xuexi\\news1.txt";
        File file=new File(filePath);
        file.createNewFile();
        System.out.println("文件创建成功！");
    }
    @Test
    //2.new File(file parent,String chile) 父目录+文件名
    public void create02O() throws IOException {
        File parentFile =new File("D:\\xuexi\\");
        String fileName="news2.txt";
        File file=new File(parentFile,fileName);
        file.createNewFile();
        System.out.println("文件2创建成功！");

    }
    @Test
    //3.new File(String parent,String chile)//根据父目录+子路径构建
    public void create03O() throws IOException {
        String parentPath="D:";
        String fileName="news3.txt";
        File file =new File(parentPath,fileName);
        file.createNewFile();
        System.out.println("文件3创建成功！");
    }

    //获取文件信息
}
